<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="bootstrap-3.3.7-dist/css/bootstrap.css"/>
</head>
<body>
	<%-- ${list} --%>
	<a class="btn btn-primary" href="/JavaWeb/user_insert.jsp">添加</a>
	<!-- <button class="btn btn-primary">添加</button> -->
	<table class="table table-bordered table-hover table-condensed table-striped">
		<tr>
			<td>ID</td>
			<td>名字</td>
			<td>年龄</td>
			<td>性别</td>
			<td>删除</td>
		</tr>
		<c:forEach items="${list}" var="user">
			<tr>
				<td>${user.id}</td>
				<td>${user.name}</td>
				<td>${user.age}</td>
				<td>${user.gender}</td>
				<td><a href="javascript:void(0)" onclick="deleteById(${user.id})">删除</a></td>
				<%-- <td><a href="/JavaWeb/deleteUser?id=${user.id}">删除</a></td> --%>
			</tr>
		</c:forEach>
		
	</table>
	
	<!-- Alt+/ -->
	<script type="text/javascript">
		function deleteById(id) {
			// boolean isDelete;
			// 在JavaScript里面所有变量的定义，全部使用var
			// var isDelete;
			var isDelete = confirm("您确定要删除么?");
			if(isDelete) {
				location.href = "/JavaWeb/deleteUser?id=" + id;
			}
		}
	</script>
</body>
</html>